home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10966 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: loki.tor.hookup.net!news
  2. From: Rajendra_Singh@msn.com (Rajendra Singh)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Beginer C please help me
  5. Date: Thu, 21 Mar 1996 04:58:33 GMT
  6. Organization: HookUp Communication Corporation, Oakville, Ontario, CANADA
  7. Message-ID: <4iqd15$ajd@loki.tor.hookup.net>
  8. References: <DoLCFx.B7x.0.bloor@torfree.net>
  9. NNTP-Posting-Host: u36u400.tor.hookup.net
  10. NNTP-Posting-User: u36u400
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. bz786@torfree.net (Sherif Asif) wrote:
  14.  
  15. >This may be a stupid mistake but "please help" me.
  16. >Thank you very much.
  17.  
  18. >#include <stdio.h>
  19. >#include <math.h>
  20. >main ()
  21. >{
  22. >float n;
  23. >n=(9/5);
  24. >printf ("n=   %1.3f\n", n);
  25. >}
  26. >I have complied and run the programme & I got the answer n=1.000
  27. >but Iam supposed to get answer 1.8.
  28. >Why I got this answer?
  29.  
  30. You are dividing an integer by an integer, hence the result is an
  31. integer.  Change one or both of the operands to a float, i. e. change
  32. 9 to 9. and/or 5 to 5., and you will get the desired result.
  33. ---
  34. Rajendra Singh, B. Sc. (Rajendra_Singh@msn.com)
  35. "What is understood need not be discussed." - Loren Adams
  36.  
  37.